package com.yuanian.timingwheel.controller;

import com.yuanian.timingwheel.context.ExecutionContext;
import com.yuanian.timingwheel.model.task.base.BaseTask;
import com.yuanian.timingwheel.statistics.LivingServer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("statistics")
public class StatisticsController {

    @GetMapping("/livingServer")
    public LivingServer getLivingServer() {
        return ExecutionContext.getInstance().getLivingServer();
    }

    @GetMapping("/loadTasks")
    public Map<Long, BaseTask> loadTasks() {
        return ExecutionContext.getInstance().getLivingServer().getLoadTasks();
    }

    @GetMapping("/waitingTasks")
    public Map<Long, BaseTask> waitingTasks() {
        return ExecutionContext.getInstance().getLivingServer().getWaitingTasks();
    }

    @GetMapping("/runningTasks")
    public Map<Long, BaseTask> runningTasks() {
        return ExecutionContext.getInstance().getLivingServer().getRunningTasks();
    }

    @GetMapping("/handledTasks")
    public Map<Long, BaseTask> handledTasks() {
        return ExecutionContext.getInstance().getLivingServer().getHandledTasks();
    }
}
